function deepClone(obj = {}) {
  if (typeof obj !== "object" || obj == null) {
    // obj 是 null 或者 是简单类型
    return obj;
  }
  let result;
  //   判断是不是数组
  if (obj instanceof Array) {
    result = [];
  } else {
    result = {};
  }
  for (const key in obj) {
    if (Object.hasOwnProperty.call(obj, key)) {
      const element = obj[key];
      result[key] = deepClone(element);
    }
  }
  return result;
}

const obj1 = {
  a: "aaa",
  b: true,
  c: 12,
  d: ["1", 2, 4],
  e: {
    age: 40,
  },
  f: {
    g: {
      h: {
        i: {
          k: [444],
          l: 22,
        },
      },
    },
  },
};

const obj2 = deepClone(obj1);

obj1.a = "bbb";
obj1.f = ["ssssssssss"];
console.table(obj1);
console.table(obj2);
